<template>
  <el-row>
    <el-button round @click="home">回首页</el-button>
    <el-button type="primary" round @click="postdata">主要按钮</el-button>
    <el-button type="success" round @click="getjinyue1">成功按钮</el-button>
    <el-button type="info" round @click="getRemot">信息按钮</el-button>
    <el-button type="warning" round>警告按钮</el-button>
    <el-button class="info2" type="danger" round>危险按钮</el-button>
    <div class="haha">{{ info }}</div>
    <div class="haha1">{{ info1 }}</div>
    <div class="haha2">{{ info2 }}</div>
  </el-row>
</template>
<script>
import { getjinyue } from '@/api/user'
import { search } from '@/api/user'
export default {
  data() {
    return {
      info: '',
      info1: this.info1,
      info2: this.info2
    }
  },
  methods: {
    // 页面跳转
    home() {
      this.$router.push('/')
    },
    // ajaxpost请求
    postdata() {
      this.$axios.post('http://192.168.2.92:9999/testpost', {
        firstName: 'Fred',
        lastName: 'Flintstone'
      }).then(response => (this.info = response.data)).catch(function(error) { console.log(error) })
    },
    // get请求
    getjinyue1() {
      getjinyue().then(response => { this.info1 = response.data })
    },
    // admin项目带的post方法使用
    getRemot() {
      const a = {
        firstName: 'Fred',
        lastName: 'Flintstone'
      }
      search(a).then(response => (this.info2 = response.code)).catch(function(error) { console.log(error) })
    }
  }
}

</script>
